Skip to content

feat: Rack 3.x and Rails 8.1+ support - #325

Merged
chadlwilson merged 10 commits into
jruby:1.3-stablefrom
chadlwilson:rack-3-upgrade
Sep 8, 2026
Merged

chadlwilson merged 10 commits into
jruby:1.3-stablefrom
chadlwilson:rack-3-upgrade

Conversation

@chadlwilson

@chadlwilson chadlwilson commented Aug 30, 2025

Copy link
Copy Markdown
Contributor

Implements spec compatibility with Rack 3.0 through 3.2.

https://github.com/rack/rack/blob/main/UPGRADE-GUIDE.md

https://github.com/rack/rack/blob/main/SPEC.rdoc

  • fully backward compatible with the existing 2.2 support
  • adds support for
    • ensuring lower case header names
    • additional SERVER_PROTOCOL env key
    • stricter multi-value handling
    • changes to query parsing semantics (delegated to underlying Rack parser) for the little-used ServletEnv style
    • Rack 3 spec-complaint #call streams (sanity test in the Sinatra example)

TODO list

  • "Invalid nested query parsing syntax" support needs review and discussion, especially the inconsistencies in the existing impl depending on
  • Need to vendor rack-session also? rackup? Or rely on Rails/frameworks to bring them in?
    • Not necessary to vendor, because not everything uses either of them
    • actually not sure we should vendor at all these days since everyone is using bundler, right?
  • Check whether removing the HeaderHash wrapper for error app has any effect on Rack 2.2
  • Remove rewindable support on 3.x since it is no longer a requirement?
    • Won't do this now at least, as things still rely on it, seemingly. (e.g the demo apps)
  • Check response header array logic is compatible
    • added much more complete specs
  • Investigate whether we supporting response hijacking at all before
    • nope, force disabled so not relevant
  • Is #call support needed?
    • implemented
  • Are the changes to remove optional environment keys worth it, or easier to just keep them?
    • Fine to remove them I think.
  • Sanity check with examples and warbler
    • Examples updated to Rack 3.2 and JRuby 10 - all seem fine.

@chadlwilson chadlwilson added this to the 1.3.0 milestone Aug 30, 2025

@kares kares left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice attempt to support both versions, seems maintainable...

Comment thread src/spec/ruby/jruby/rack/integration_spec.rb Outdated
Comment thread src/main/ruby/rack/handler/servlet/servlet_env.rb Outdated
Comment thread src/main/ruby/rack/handler/servlet/servlet_env.rb Outdated
@chadlwilson chadlwilson linked an issue Sep 3, 2025 that may be closed by this pull request
@chadlwilson
chadlwilson force-pushed the rack-3-upgrade branch 2 times, most recently from 52944a0 to c4cd00e Compare September 6, 2025 10:42
@chadlwilson
chadlwilson force-pushed the rack-3-upgrade branch 2 times, most recently from 6279ba8 to c5a7a6e Compare September 25, 2025 18:03
@chadlwilson
chadlwilson force-pushed the rack-3-upgrade branch 3 times, most recently from 0b70f23 to 196095b Compare October 11, 2025 06:01
@chadlwilson chadlwilson self-assigned this Oct 22, 2025
@chadlwilson
chadlwilson force-pushed the rack-3-upgrade branch 2 times, most recently from 5f1d489 to b63259a Compare October 27, 2025 17:32
Comment thread examples/rails8/Gemfile.lock Outdated
@chadlwilson
chadlwilson force-pushed the rack-3-upgrade branch 2 times, most recently from df4109d to 476247d Compare March 5, 2026 04:21
@chadlwilson chadlwilson changed the title (experimental WIP) Rack 3.x support [feat] WIP Rack 3.x support Mar 13, 2026
@chadlwilson chadlwilson changed the title [feat] WIP Rack 3.x support [feat] Rack 3.x and Rails 8.1+ support Mar 16, 2026
@chadlwilson
chadlwilson force-pushed the rack-3-upgrade branch 3 times, most recently from 309c7e7 to 82c16bf Compare April 21, 2026 16:42
@chadlwilson
chadlwilson force-pushed the rack-3-upgrade branch 4 times, most recently from b06caed to 3f56596 Compare September 8, 2026 15:09
chadlwilson and others added 7 commits September 8, 2026 23:49
Rack 3.x allows any header value to be an Array of Strings. The
Content-Type/Content-Length/Transfer-Encoding special cases coerced the
value directly (asJavaString/to_i) and raised on Arrays - now a single
value Array is unwrapped, and multi value Arrays take the generic
addHeader-per-element path instead of erroring.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
DefaultEnv used HttpServletRequest#getHeader which only returns the
first value of a repeated header, dropping e.g. X-Forwarded-For hops.
All values are now joined with ', ' (and Cookie headers re-combined
with '; ' per RFC 6265 / RFC 7540), falling back to getHeader for
containers restricting getHeaders access.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The newline-splitting header write path called chomp! on each yielded
value - a frozen String ending in a newline raised FrozenError, and
non-frozen app-owned header values were being modified in place.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…upport

Replace the earlier non-compliant "unofficial extension" implementation with proper support.
@chadlwilson
chadlwilson marked this pull request as ready for review September 8, 2026 15:52
@chadlwilson
chadlwilson merged commit 8dc49a9 into jruby:1.3-stable Sep 8, 2026
40 checks passed
@chadlwilson
chadlwilson deleted the rack-3-upgrade branch September 8, 2026 15:54
pull Bot pushed a commit to soitun/killbill-admin-ui-standalone that referenced this pull request Sep 15, 2026
…v breakage

CI/release workflows: bump java-version 11 -> 21 and ruby-version
jruby-9.4.15.0 -> jruby-10.0.6.0 (LTS line) throughout.

Gemfile:
- Pin rack ~> 2.2.0 and jruby-rack ~> 2.0.0. jruby-rack does not yet
  correctly implement the Rack 3 spec (jruby/jruby-rack#325, unreleased),
  and this repo was silently resolving Rack 3.2.7 against jruby-rack 1.2.8
  (pre-2.0 jruby-rack vendored a fallback rack instead of declaring a real
  dependency). jruby-rack 2.0.0 is the line that targets JRuby 10/JDK21
  (compiled against jakarta.servlet, requires Tomcat 10+).
- Pin json ~> 2.21: json 3.0 dropped the quirks_mode keyword that
  ActiveSupport::JSON.encode still passes, crashing js-routes' eager route
  JSON generation at boot.
- Add explicit csv dependency: csv is now a Ruby 3.4 "bundled gem" (not
  default), and kaui's CSV-export controllers require it directly.
- Bump jruby-jars to 10.0.6.0, bundler to >= 2.7.2 (matches JRuby 10.0.x's
  bundled bundler; loosened from ~> to >= so it also works under JRuby
  10.1.x's bundler 4.0.x), warbler to ~> 2.1.2.

config/application.rb: work around a sorbet-runtime/js-routes crash under
JRuby 10 (Ruby 4.0 compat) by disabling sorbet-runtime checks, matching the
existing workaround in killbill-admin-ui's test/dummy app.

build.sh / README: update the JRuby version check/messaging.

Reverted the config/warble.rb dechunk-disabling workaround that was needed
to work around the Rack 3 issue above; no longer needed once Rack is
pinned back to 2.2.x (Rack::Chunked works natively again).

Companion PRs: killbill-cloud (Tomcat 9 -> 10.1, JDK 21 base image, since
jruby-rack 2.0 requires jakarta.servlet/Tomcat 10+) and gh-actions-shared
(cloudsmith_release.yml ruby_version input + bundler bump).

Validated end-to-end: real bundle install + build.sh + warble WAR
packaging + actual deployment/boot on a local Tomcat 10.1.43 under JDK21,
confirmed via HTTP 302 response with correct session cookie and chunked
transfer encoding, and a working JDBC connection.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rack 3.x / Rails 8.1 support

2 participants